package co.th.bjc.md.dao.impl;

import java.math.BigDecimal;

import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import co.th.bjc.md.dao.RegionDao;
import co.th.bjc.md.model.Region;

public class RegionDaoImpl extends HibernateDaoSupport implements RegionDao{

	@Override
	public Region findByID(BigDecimal regionId) throws Exception {
		Region region = (Region) getHibernateTemplate().get(Region.class, regionId);
		region.setProvince(region.getProvince());
		getHibernateTemplate().evict(region);
		return region;
	}

	@Override
	public Region find(Region region) throws Exception {
		Session session = getSession();
		region = (Region) session.get(Region.class, region.getRegionId());
		region.getProvince();
		session.close();
		return region;
	}

}
